<template>
  <div>
    <el-dialog
      title="题目审核"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
    >
      <!-- 答题框 -->
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item>
          <el-radio-group v-model="form.resource">
            <el-radio label="1">通过</el-radio>
            <el-radio label="2">拒绝</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="form.desc"
            type="textarea"
            placeholder="请输入审核意见"
          ></el-input>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="childSetDialogVisible">取 消</el-button>
        <el-button type="primary" @click="childSetDialogVisible"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '../../../api/hmmm/questions'

export default {
  name: 'Audit',
  components: {},
  props: {
    dialogVisible: {
      type: Boolean,
      required: true
    },
    setDialogVisible: {
      type: Function
    },

    listValue: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
    //   dialogVisible: false
      form: {
        resource: '',
        desc: ''
      }
    }
  },
  async  created() {
    // console.log(this.listValue, '总数居')
  },
  mounted() {},
  methods: {
    async  childSetDialogVisible() {
      this.$emit('setDialogVisible')
      try {
        if (this.form.desc === '') {
          this.$message.error('错了哦')
        } else {
          //  提交审核
          await choiceCheck({
            id: this.listValue.id,
            chkState: Number(this.form.resource),
            chkRemarks: this.form.desc
          })
          // console.log(res, '审核意见')
          // 调用父亲的方法
          this.$parent.AgeChoice()
        }
      } catch (error) {
        this.$message.error('错了哦，这是一条错误消息')
      }
    },
    handleClose(done) {
    //   this.$confirm('确认关闭？')
    //     .then(_ => {
      this.$emit('setDialogVisible')
      // })
      // .catch(_ => {})
    }
  }
}

</script>

<style lang="scss" scoped>
</style>
